class TFBlockShield extends Actor;

var tfShield shield;

replication
{
	// Things the server should send to the client.
	reliable if ( Role == ROLE_Authority )
		Shield;
}

function PostBeginPlay()
{
    SetStaticMesh(none);
    SetTimer(0.1, true);
}

function timer()
{
    if(shield==none)
    {
        destroy();
        return;
    }

    if(shield.grade<3) return;

    if(shield.health<=shield.maxhealth*0.5)
    {
        if(staticmesh!=none)
        {
            PlaySound(sound'TFMedia.tfBlockShieldOpen',,1);
            SetStaticMesh(none);
            if(shield.MyTeam==0) shield.setstaticmesh(StaticMesh'TFMedia.Buildings.tfShieldRed');
            else shield.setstaticmesh(StaticMesh'TFMedia.Buildings.tfShieldBlu');
            SetCollision(false);
        }
        Settimer(1, true);
        return;
    }
    else if(shield.near!=none && staticmesh!=none)
    {
        PlaySound(sound'TFMedia.tfBlockShieldOpen',,1);
        SetStaticMesh(none);
        if(shield.MyTeam==0) shield.setstaticmesh(StaticMesh'TFMedia.Buildings.tfShieldRed');
        else shield.setstaticmesh(StaticMesh'TFMedia.Buildings.tfShieldBlu');
        SetCollision(false);
        Settimer(2, true);
        return;
    }
    else if(staticmesh==none)
    {
        PlaySound(sound'TFMedia.tfBlockShieldClose',,1);
        SetStaticMesh(default.staticmesh);
        if(shield.MyTeam==0) shield.setstaticmesh(StaticMesh'TFMedia.Buildings.tfShieldRedWBS');
        else shield.setstaticmesh(StaticMesh'TFMedia.Buildings.tfShieldBluWBS');
        SetCollision(true);
        SetTimer(0.1, true);
        return;
    }
}

defaultproperties
{
     DrawType=DT_StaticMesh
     StaticMesh=StaticMesh'TFMedia.fX.tfBlockShield'
     bHidden=True
     bTrailerSameRotation=True
     bNetTemporary=True
     Physics=PHYS_Trailer
     RemoteRole=ROLE_SimulatedProxy
     DrawScale=1.550000
     bUnlit=True
     bGameRelevant=True
     bBlockActors=True
     bBlockPlayers=True
     bBlockZeroExtentTraces=False
     bBlockKarma=True
}
